#include "mainwindow.h"
#include "./ui_mainwindow.h"
static int page =1;
static QPushButton *lastClickedButton = nullptr;
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_pageEdit_editingFinished()
{
    QString text = ui->pageEdit->text();
    bool ok;
    page = text.toInt(&ok);
    if (ok) {

        ui->pageEdit->setText(QString::number(page));
    }
}


void MainWindow::on_lastButton_clicked()
{
    if(page>1){
        page--;
        ui->pageEdit->setText(QString::number(page));
    }
}


void MainWindow::on_nextButton_clicked()
{
    page++;
    ui->pageEdit->setText(QString::number(page));
}


void MainWindow::on_shownameButton_clicked()
{if(lastClickedButton==nullptr){
         ui->shownameButton->setStyleSheet("border: 2px solid red;");
        lastClickedButton=ui->shownameButton;
    }else{
        ui->shownameButton->setStyleSheet("border: 2px solid red;");
             lastClickedButton->setStyleSheet("border: 2px solid transparent;""background-color: rgb(181, 255, 8);");
        lastClickedButton=ui->shownameButton;

    }


}



void MainWindow::on_shownameButton_2_clicked()
{
    if(lastClickedButton==nullptr){
        ui->shownameButton_2->setStyleSheet("border: 2px solid red;");
        lastClickedButton=ui->shownameButton_2;
    }else{
        ui->shownameButton_2->setStyleSheet("border: 2px solid red;");
            lastClickedButton->setStyleSheet("border: 2px solid transparent;""background-color: rgb(181, 255, 8);");
        lastClickedButton=ui->shownameButton_2;

    }
}


void MainWindow::on_shownameButton_3_clicked()
{
    if(lastClickedButton==nullptr){
        ui->shownameButton_3->setStyleSheet("border: 2px solid red;");
        lastClickedButton=ui->shownameButton_3;
    }else{
        ui->shownameButton_3->setStyleSheet("border: 2px solid red;");
        lastClickedButton->setStyleSheet("border: 2px solid transparent;""background-color: rgb(181, 255, 8);");
        lastClickedButton=ui->shownameButton_3;

    }
}


void MainWindow::on_shownameButton_4_clicked()
{

    if(lastClickedButton==nullptr){
        ui->shownameButton_4->setStyleSheet("border: 2px solid red;");
        lastClickedButton=ui->shownameButton_4;
    }else{
        ui->shownameButton_4->setStyleSheet("border: 2px solid red;");
           lastClickedButton->setStyleSheet("border: 2px solid transparent;""background-color: rgb(181, 255, 8);");
        lastClickedButton=ui->shownameButton_4;

    }
}


void MainWindow::on_shownameButton_5_clicked()
{
    if(lastClickedButton==nullptr){
        ui->shownameButton_5->setStyleSheet("border: 2px solid red;");
        lastClickedButton=ui->shownameButton_5;
    }else{
        ui->shownameButton_5->setStyleSheet("border: 2px solid red;");
        lastClickedButton->setStyleSheet("border: 2px solid transparent;""background-color: rgb(181, 255, 8);");
        lastClickedButton=ui->shownameButton_5;

    }
}


void MainWindow::on_shownameButton_7_clicked()
{
    if(lastClickedButton==nullptr){
        ui->shownameButton_7->setStyleSheet("border: 2px solid red;");
        lastClickedButton=ui->shownameButton_7;
    }else{
        ui->shownameButton_7->setStyleSheet("border: 2px solid red;");
        lastClickedButton->setStyleSheet("border: 2px solid transparent;""background-color: rgb(181, 255, 8);");
        lastClickedButton=ui->shownameButton_7;

    }
}


void MainWindow::on_shownameButton_6_clicked()
{
    if(lastClickedButton==nullptr){
        ui->shownameButton_6->setStyleSheet("border: 2px solid red;");
        lastClickedButton=ui->shownameButton_6;
    }else{
        ui->shownameButton_6->setStyleSheet("border: 2px solid red;");
        lastClickedButton->setStyleSheet("border: 2px solid transparent;""background-color: rgb(181, 255, 8);");
        lastClickedButton=ui->shownameButton_6;

    }
}


void MainWindow::on_shownameButton_8_clicked()
{

    if(lastClickedButton==nullptr){
        ui->shownameButton_8->setStyleSheet("border: 2px solid red;");
        lastClickedButton=ui->shownameButton_8;
    }else{
        ui->shownameButton_8->setStyleSheet("border: 2px solid red;");
        lastClickedButton->setStyleSheet("border: 2px solid transparent;""background-color: rgb(181, 255, 8);");
        lastClickedButton=ui->shownameButton_8;

    }
}


void MainWindow::on_shownameButton_9_clicked()
{
    if(lastClickedButton==nullptr){
        ui->shownameButton_9->setStyleSheet("border: 2px solid red;");
        lastClickedButton=ui->shownameButton_9;
    }else{
        ui->shownameButton_9->setStyleSheet("border: 2px solid red;");
        lastClickedButton->setStyleSheet("border: 2px solid transparent;""background-color: rgb(181, 255, 8);");
        lastClickedButton=ui->shownameButton_9;

    }
}


void MainWindow::on_shownameButton_10_clicked()
{
    if(lastClickedButton==nullptr){
        ui->shownameButton_10->setStyleSheet("border: 2px solid red;");
        lastClickedButton=ui->shownameButton_10;
    }else{
        ui->shownameButton_10->setStyleSheet("border: 2px solid red;");
        lastClickedButton->setStyleSheet("border: 2px solid transparent;""background-color: rgb(181, 255, 8);");
        lastClickedButton=ui->shownameButton_10;

    }
}

